#!/usr/bin/env python
import face_recognition
import cv2
import numpy as np
import os
import pickle
import shutil
import sqlite3
foto_face = []
foto_metadata = []
i=0
name=input('Введите номер цеха: ')
name=str(name_zech)
for dirpath, dirnames, filenames in os.walk(name_zech+"/"): 
   for filename in filenames:
         try:
          if filename:
            i=i+1
            dd=dirpath.split("/")[1]            
            image = face_recognition.load_image_file(os.path.join(dirpath, filename))
            face_encoding = face_recognition.face_encodings(image)[0] # эмбеддинги для каждого лица
            foto_face.append(face_encoding)
            foto_metadata.append(dd)
            print("Файл - save:", dd)     #,"\n" 
         except: 
           print("Файл c error:", os.path.join(dirpath, filename))


with open("faces_"+name_zech+".dat", "wb") as face_data_file:
        face_data = [foto_face, foto_metadata]
        pickle.dump(face_data, face_data_file)
        print("Готово")
